package org.karai.frame.core.base;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewbinding.ViewBinding;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

public abstract class FrameFragment<T extends ViewBinding , P extends IBasePresenter> extends Fragment implements IBaseView ,ILifeEvent{



    public P persenter ;
    public T binding ;


    /**
     * 用于请求的参数
     */
    public Map<String , Object> requestParams = new HashMap<>();

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        this.binding = (T) setLayOut(inflater , container);
        this.persenter = setPersenter();
        if (this.binding == null) {
            throw new NullPointerException("binding 视图绑定失败");
        }
        // 时间调用
        startEvent();
        return this.binding.getRoot();
    }


    public abstract P setPersenter() ;

    public abstract  ViewBinding setLayOut(LayoutInflater inflater, ViewGroup container) ;
}
